<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('问题bug审核列表')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    const sys_use_status = [[${@sysDictDataServiceImpl.listDictDataByTypeSign('sys_use_status')}]];
    const tiku_question_type = [[${@sysDictDataServiceImpl.listDictDataByTypeSign('tiku_question_type')}]];
    const tiku_question_audit_status = [[${@sysDictDataServiceImpl.listDictDataByTypeSign('tiku_question_audit_status')}]];
    const tiku_question_year = [[${@sysDictDataServiceImpl.listDictDataByTypeSign('tiku_question_year')}]];
    const  prefix = ctx + "tiku/question/bug";

    $(function () {
        const options = {
            url: prefix + "/list",
            modalName: "题目bug审核",
            sortName: "submitTime",
            sortOrder: "desc",
            pageSize: 30,
            columns: [{
                checkbox: true
            },
                {
                    field: 'id',
                    title: 'ID',
                    sortable: true,
                    visible: false
                },
                {
                    field: 'content',
                    title: '内容摘要'
                },
                {
                    field: 'submitTime',
                    title: '提交时间',
                    sortable: true
                },
                {
                    field: 'submitRemark',
                    title: '备注'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        const actions = [];
                        actions.push('<a class="btn btn-info btn-xs ' + '" href="javascript:void(0)" onclick="submitDetail(\'' + row.id + '\')"><i class="fa fa-chevron-circle-right"></i>详情</a> ');
                        actions.push('<a class="btn btn-primary btn-xs ' + '" href="javascript:void(0)" onclick="pass(\'' + row.id + '\')"><i class="fa fa-chevron-circle-right"></i>通过并合并</a>');
                        actions.push('<a class="btn btn-danger btn-xs ' + '" href="javascript:void(0)" onclick="unPass(\'' + row.id + '\')"><i class="fa fa-remove"></i>未通过</a>');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });

    /*查看题目详情*/
    function submitDetail(id) {
        const url = prefix+'/detail/' + id;
        $.modal.open("题目详情", url);
    }


    /*审核通过*/
    function pass(id) {
        $.ajax({
            cache: true,
            type: "POST",
            url: prefix + "/pass/" + id,
            async: false,
            error: function (request) {
                $.modal.alertError("系统错误");
            },
            success: function (data) {
                $.operate.successCallback(data);
            }
        });
    }

    /*审核未通过*/
    function unPass(id) {
        $.ajax({
            cache: true,
            type: "POST",
            url: prefix + "/unPass/" + id,
            async: false,
            error: function (request) {
                $.modal.alertError("系统错误");
            },
            success: function (data) {
                $.operate.successCallback(data);
            }
        });
    }
</script>
</body>
</html>